# DVHealth Frontend Dockerfile
# 构建阶段
FROM node:20-alpine as build

# 设置工作目录
WORKDIR /app

# 设置npm镜像源加速依赖安装
RUN npm config set registry https://registry.npm.taobao.org

# 复制依赖文件
COPY package*.json ./

# 安装依赖
RUN npm ci

# 复制源代码
COPY . .

# 构建生产版本
RUN npm run build

# 生产阶段
FROM nginx:alpine

# 移除默认配置
RUN rm -rf /etc/nginx/conf.d/*

# 复制构建产物到Nginx目录
COPY --from=build /app/dist /usr/share/nginx/html

# 复制Nginx配置文件
COPY nginx.conf /etc/nginx/conf.d/default.conf

# 暴露端口
EXPOSE 80

# 启动Nginx
CMD ["nginx", "-g", "daemon off;"]